package com.github.prontera.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.RequestLogging;
import com.github.prontera.common.filter.IgnoreAuth;
import com.github.prontera.domain.Regions;
import com.github.prontera.model.request.RegionsRequest;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.RegionsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;


/**
 * 标签
 */
@RestController
@Api(value = "标签")
@RequestMapping(value = ApiVersion.MANAGE_V1_PREFIX+"/regions")
public class RegionsController{

	@Autowired
	private RegionsService regionsService;
	
	
	/**
	 * 查找省市区
	 */
	
	@IgnoreAuth
	@RequestMapping(value = "find", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "查找省市区" , notes = "查找省市区")
	public ObjectDataResponse<List<Regions>> find(@RequestBody RegionsRequest regionsRequest){
		Regions regions=new Regions();
		regions.setRegionGrade(regionsRequest.getType().getCode());
		regions.setParentRegionCode(regionsRequest.getParentId());
		List<Regions> regionsList=regionsService.find(regions);
		return new ObjectDataResponse<List<Regions>>(regionsList);
	}
	
}
